<template>
	<div v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
		element-loading-background="rgba(0, 0, 0, 0.8)">
		<component :is="currentTabComponent" :info="info"></component>
	</div>
</template>
<script>
	import vDataBase from "./TEDatabaseDialog.vue";
	import vSever from "./dialogServer";
	import {
		GetItem,
		DeleteItem
	} from "@/utils/TodayExaminedataStore";
	export default {
		components: {
			vDataBase,
			vSever,
		},
		created() {
			this.loading = true;
			GetItem(sessionStorage.getItem("examineId"))
				.then((_) => {
					this.info = _[0].Info;
					this.initData();
					this.loading = false;
				})
				.catch((e) => {
					console.log(e)
					this.$message.error("异常");
					setTimeout(() => {
						window.close();
					}, 3000);
				});
		},

		data() {
			return {
				currentTabComponent: "",
				info: "",
				loading: false,
			};
		},
		methods: {
			initData() {
				this.currentTabComponent =
					this.info.type == "DataBase" ? "vDataBase" : "vSever";
			},
			clear() {
				DeleteItem(Number(sessionStorage.getItem("examineId")))
					.then((_) => {})
					.catch((e) => {
						console.log(e);
					});
				sessionStorage.clear("examineId");
				window.close();
			},
		},
		beforeDestroy() {
			this.clear();
		},
	};
</script>
<style scoped>
</style>